package com.leetcode.algorithm.y22.m06;

/**
 * 190. 颠倒二进制位
 * 
 * https://leetcode.cn/problems/reverse-bits/
 * 
 * @author jie.deng
 *
 */
public class Question0190Solution01 {
	
    // you need treat n as an unsigned value
	public int reverseBits(int n) {
		int x = 0;
		for (int i = 0; i < 32; i++) {
			x <<= 1;
			x |= (n & 1);
			n >>>= 1;
		}
		return x;
	}
    
}